<template>
	<view>
		<view class="contact" v-for="(item,index) in list" @click="messages(item,index)">
			<view class="contact_os" v-if="item.isRead == false"></view>
			<view class="img">
				<image src="../../static/iocn36.png"></image>
			</view>
			<view>
				<text>系统消息</text>
				<text>{{item.contents}}</text>
			</view>
		</view>
		<view v-if="list == 0">
			<u-empty mode="message" icon="http://cdn.uviewui.com/uview/empty/message.png"></u-empty>
		</view>
		<view class="zwsj">{{ moreContent }}</view>
		<view>
			<Tabbar :current="'1'"></Tabbar>
		</view>
	</view>
</template>

<script>
	import {
		GetSysMsg,
		ReadMsg
	} from '@/public/Api/update.js'
	import {
		setValue,
		getValue
	} from '@/public/storeage/index.js'
	import Tabbar from '@/pages/navigation/sjnavigation.vue';
	export default {
		components: {
			//注册组件
			Tabbar
		},
		data() {
			return {
				list: [],
				skipCount: 0, // 页数
				maxResultCount: 10, //每页总数
				isLoadMore: false, //是否加载中
			};
		},
		onLoad() {
			// var statusact = getValue('statusact')
			// if (statusact == '停用') {
			// 	uni.reLaunch({
			// 		url: '/pages/Loginas/index'
			// 	})
			// }
			// uni.hideHomeButton()
		},
		onShow() {
			this.GetSysMsg()
		},
		//监听页面触底函数
		onReachBottom() {
			this.skipCount += 10
			this.GetSysMsg()
		},
		methods: {
			// 获取通话记录
			async GetSysMsg() {
				var skipCount = this.skipCount
				var maxResultCount = this.maxResultCount
				var userId = getValue('id')
				try {
					const {
						data: res
					} = await GetSysMsg({
						skipCount,
						maxResultCount,
						userId
					})
					this.list = this.list.concat(res.result.items)
				} catch (e) {}
			},

			async messages(item,index) {
				var id = item.id
				this.list[index].isRead = true
				
				// return false
				try {
					const {
						data: res
					} = await ReadMsg({
						id
					})
					console.log(res)
				} catch (e) {}
			},
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #f7f7f7;
		padding: 20upx;
	}

	.contact {
		background-color: #fff;
		padding: 25upx;
		border-radius: 17.52upx;
		box-shadow: 1.75upx 1.75upx 7.01upx 0px #cccccc, 1.75upx 1.75upx 7.01upx 0px #cccccc;
		margin-bottom: 30upx;
		display: flex;
		align-items: center;
		// justify-content: space-between;
		position: relative;

		.contact_os {
			position: absolute;
			top: 10upx;
			left: 10upx;
			width: 22upx;
			height: 22upx;
			background-color: #EF4D3D;
			border-radius: 50%;
			padding: 0 !important;
		}

		image {
			width: 67upx;
			height: 67upx;
		}

		view {
			padding-left: 20upx;

			text {
				display: block;
				font-size: 25upx;
				font-weight: bold;
				padding-left: 10upx;
				margin-top: -5upx;
			}
		}
	}
</style>
